//
//  SDSharedViewCell.m
//  SuperDoctor
//
//  Created by 年浩杰 on 16/7/7.
//  Copyright © 2016年 SD. All rights reserved.
//

#import "SDSharedViewCell.h"

@interface SDSharedViewCell ()

@property (nonatomic,strong) UILabel *boyName;

@property (nonatomic,strong) UILabel *girlName;

@property (nonatomic,strong) UILabel *time;

@property (nonatomic,strong) UILabel *type;

@property (nonatomic,strong) UILabel *share;

@property (nonatomic,strong) UIImageView *image;

@property (nonatomic,strong) UIImageView *jiantou;

@end

@implementation SDSharedViewCell

- (void)setModel:(SDSharedModel *)model {
    _model = model;
    
    self.boyName.text = model.boyName;
    
    self.girlName.text = model.girlName;
    
    self.time.text = [NSString stringWithFormat:@"%d",model.time.intValue];
    
    self.type.text = model.type;
    
    self.share.text = model.share;
    
    self.image.image = [UIImage imageNamed:model.image];
    
    self.jiantou.image = [UIImage imageNamed:model.jiantou];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
//        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
        [self setupUI];
        
    }
    return self;
}

- (void)setupUI {
    //图片
   UIImageView * image = [[UIImageView alloc] init];
    
    self.image = image;
    
    [self.contentView addSubview:self.image];
    
    UIImageView * jiantou = [[UIImageView alloc] init];
    
    self.jiantou = jiantou;
    
    [self.contentView addSubview:self.jiantou];
    //男孩名字
    UILabel * boyName =[[UILabel alloc]init];
    
    self.boyName = boyName;
    
    [self.contentView addSubview:boyName];
    //女孩名字
    UILabel * girlName =[[UILabel alloc]init];
    
    self.girlName = girlName;
    
    [self.contentView addSubview:girlName];
    //时间
    UILabel * time =[[UILabel alloc]init];
    
    self.time = time;
    
    [self.contentView addSubview:time];
    //类型
    UILabel * type =[[UILabel alloc]init];
    
    self.type = type;
    
    [self.contentView addSubview:type];
    //分享
    UILabel * share =[[UILabel alloc]init];
    
    self.share = share;
    
    [self.contentView addSubview:share];
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    [self.image mas_makeConstraints:^(MASConstraintMaker *make) {
      
        make.top.mas_equalTo(self.contentView.mas_top).offset(5);
        
        make.left.mas_equalTo(self.contentView.mas_left).offset(5);
        
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-5);
        
        make.width.mas_equalTo(self.contentView.mas_height);
    }];
    
    [self.jiantou mas_makeConstraints:^(MASConstraintMaker *make)
    {
//        make.top.offset(44);
        
        make.height.mas_equalTo(15);
        
        make.right.offset(-15);
        
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        
    }];
//
    [self.boyName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.image.mas_right).offset(10);
        
        make.top.mas_equalTo(self.image.mas_bottom).offset(-70);
        
        
        
    }];
    
    [self.girlName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.image.mas_right).offset(10);
        
        make.top.mas_equalTo(self.image.mas_bottom).offset(-20);
        
    }];
    

    
    
}
@end
